Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add depends_on :linux and :macos #3270

Merged
merged 2 commits into from
Oct 18, 2017
Merged

Conversation

sjackman
Copy link
Contributor

@sjackman sjackman commented Oct 5, 2017

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew tests with your changes locally?

Allow a formula to declare whether it depends on macOS or Linux.

@@ -108,7 +108,8 @@ def parse_symbol_spec(spec, tags)
case spec
when :x11 then X11Requirement.new(spec.to_s, tags)
when :xcode then XcodeRequirement.new(tags)
when :macos then MinimumMacOSRequirement.new(tags)
when :linux then LinuxRequirement.new
when :macos then tags.empty? ? MacOSRequirement.new : MinimumMacOSRequirement.new(tags)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make MacOSRequirement.new handle the tags.empty? case instead of having the meaning overloaded.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@ilovezfs
Copy link
Contributor

ilovezfs commented Oct 6, 2017

How do you specify both that macOS is required and that a minimum version is required? My understanding is depends_on :macos => :el_capitan is a no-op on Linux.

@sjackman
Copy link
Contributor Author

sjackman commented Oct 6, 2017

To specify that both that macOS is required and that a minimum version is required:

depends_on :macos
depends_on MinimumMacOSRequirement => :el_capitan

@ilovezfs
Copy link
Contributor

ilovezfs commented Oct 6, 2017

That seems like pretty yucky syntax to me.

@sjackman sjackman force-pushed the os-requirement branch 2 times, most recently from c82d73b to eb3ba7c Compare October 6, 2017 06:10
super
end

satisfy(build_env: false) { MacOS.version >= @version }
satisfy(build_env: false) do
if @version
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

next false if !OS.mac? || !@version

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be worth taking the same approach below, too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Thanks for the suggestion, Mike. The logic needed tweaking. When OS.mac? is true and @version is nil, the result should be true.

@@ -3,18 +3,32 @@
class MinimumMacOSRequirement < Requirement
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth renaming this now to be consistent, what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name of the class is a component of the DSL. The name MinimumMacOSRequirement is used by two formulae in core:

nordugrid-arc.rb:  depends_on MinimumMacOSRequirement => :yosemite
phantomjs.rb:  depends_on MinimumMacOSRequirement => :lion

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can add it to compat and update them to use depends_on :macos

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. Would you like to suggest a name?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MacOSRequirement?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've renamed MinimumMacOSRequirement to MacOSRequirement and added MinimumMacOSRequirement to compat.

@@ -0,0 +1,3 @@
require "requirements/macos_requirement"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stick this file's contents in homebrew/Library/Homebrew/compat/requirements.rb

fatal true

def initialize(tags = [])
@version = MacOS::Version.from_symbol tags.first unless tags.empty?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MacOS::Version.from_symbol(tags.first) just to aid visual parsing.


satisfy(build_env: false) do
next false if !OS.mac? && !@version
next true if !OS.mac? || !@version
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a little hard to parse above. Can you maybe make it if/elses? This may contradict what I said earlier: sorry!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Factoring out the minimum_version? utility method also helped make this logic more clear.

end

def message
return "macOS is required." if !OS.mac? || !@version
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if !OS.mac? || !@version could be a utility method, I think, it's repeated 3 times.

super
end

def minimum_version?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minimum_version_provided or passed or specified something would be nicer to make it clear that this doesn't mean the minimum version is met.

@MikeMcQuaid
Copy link
Member

Tests failing on Linux (shouldn't assume MacOS is specified there): https://travis-ci.org/Homebrew/brew/jobs/285144949

@sjackman
Copy link
Contributor Author

sjackman commented Oct 9, 2017

Fixed up.

@MikeMcQuaid
Copy link
Member

@sjackman Still got 🔴.

@sjackman
Copy link
Contributor Author

😬

@sjackman
Copy link
Contributor Author

Good to merge?

@sjackman sjackman mentioned this pull request Oct 16, 2017
5 tasks
end

satisfy(build_env: false) do
next OS.mac? || @version unless minimum_version_specified?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, last nite: can you split this into two next checks and return a boolean value?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@MikeMcQuaid MikeMcQuaid merged commit c7d21da into Homebrew:master Oct 18, 2017
@MikeMcQuaid
Copy link
Member

Thanks @sjackman and sorry for the nit picking!

@sjackman sjackman deleted the os-requirement branch October 18, 2017 15:13
@sjackman
Copy link
Contributor Author

No worries. Thanks for merging, Mike.

@Homebrew Homebrew locked and limited conversation to collaborators May 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants